package com.ken.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ken.dto.GoodsSalesDTO;
import com.ken.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderMapper extends BaseMapper<Orders> {
    @Update("update orders set status=#{orderStatus},pay_status=#{orderPaidStatus},checkout_time=#{checkOutTime} where number=#{orderNumber}")
    void updateStatus(Integer orderStatus, Integer orderPaidStatus, LocalDateTime checkOutTime, String orderNumber);

    @Select("select * from orders where number=#{orderNumber} and user_id=#{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);

    List<GoodsSalesDTO> getSalesTop(LocalDateTime beginTime, LocalDateTime endTime, Integer completed);
}
